// pages/coursetable/coursetable.js
var app = getApp()
Page({
  data: {
    sid: null,
    colorArrays: ["#85B8CF", "#90C652", "#D8AA5A", "#FC9F9D", "#0A9A84", "#61BC69", "#12AEF3", "#E29AAD"],
    mlist: null,
    courselong: 2,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    console.log("是学生吗" + app.globalData.isStudent);
    if (app.globalData.isStudent) {
      that.setData({
        sid: app.globalData.sId
      })
    }

    getTodayCourse(that, this.data.sid);

  },

})
/** 
* 获得一周课程
*/
function getTodayCourse(that, sid) {
  console.log(that)
  wx.request({
    url: `https://geek-team.xin/schedule/wx_getScheduleByWeek`,
    method: 'POST',
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    data: {
      sId: sid
    },
    success(res) {
      if (res.data != []) {
        that.setData({
          mlist: res.data
        })
        console.log(res.data)
      }
    },
    fail: (e) => console.log(e)
  })
}